<?php
function __autoload($className)
{
        if(!defined("APIDIR")) {
            die("API directory is not defined!");
        }

        $utilClasses=array("Client","Get","Post","System");
        $exceptionClasses=array("DatabaseException","TransferException");
        if(!in_array($className,array_merge($utilClasses,$exceptionClasses))) {
            if(file_exists(APIDIR."client/".$className.".php")) {
		require_once (APIDIR."client/".$className.".php");
            } else if (file_exists(APIDIR."database/".$className.".php")) {
                require_once (APIDIR."database/".$className.".php");
            } else if (file_exists(APIDIR."/".$className.".php")) {
                require_once (APIDIR."/".$className.".php");
            }
        }
        foreach($exceptionClasses as $c)
        {
            include("exceptions/".$c.".php");
        }
        foreach($utilClasses as $c)
        {
            include("utils/".$c.".php");
        }
        
}
?>